using System;

namespace Rarous.NForms {
  public class ListValidationSummaryFormatter : IFormatter {

    public HtmlElement Format() {
      if (Form.Messages.Count == 0) {
        return new HtmlElement(String.Empty);
      }

      var ul = new HtmlElement("ul", new {
        Class = "summary"
      });

      foreach (string message in Form.Messages) {
        ul.AddChild("li", new {
          Text = message
        });
      }

      return ul;
    }

    public Form Form {
      get;
      set;
    }
  }
}
